package com.example.myapplication.tools;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class NetworkUtils {

	public static boolean getNetworkState(Context context){
    	try {
			ConnectivityManager connectivity = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
			if (connectivity != null) {
				// 获取网络连接管理的对象
				NetworkInfo info = connectivity.getActiveNetworkInfo();
				if (info != null && info.isConnected()) {
					// 判断当前网络是否已经连接
					if (info.getState() == NetworkInfo.State.CONNECTED) {
						return true;
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
    }

	public static String getWifiQuality(int issr,int speed){
		String str = "";
		if (issr <= 60) {
			str = "良好";
		} else if (issr <= 80) {
			str = "一般";
		} else if (issr <= 100 || speed <60) {
			str = "差";
		} else{
			str = "差";
		}
		return str;
	}

}
